package aimis;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Test {
    public static  void main(String args[]) throws JsonProcessingException {

        String json= """
                {
                    "pagination": {
                        "count": 6,
                        "cursor_hash": "7afb520f30d82f8baabc9b22e419b240",
                        "cursors": [
                            null
                        ],
                        "sort": null
                    },
                    "scans": [
                        {
                            "criticality": 10,
                            "current_session": {
                                "event_level": 2,
                                "progress": 100,
                                "scan_session_id": "ecf93ac8-d5fa-4498-8240-c7db884c5ff4",
                                "severity_counts": {
                                    "high": 0,
                                    "info": 0,
                                    "low": 0,
                                    "medium": 0
                                },
                                "start_date": "2023-04-12T21:06:41.266233+08:00",
                                "status": "completed",
                                "threat": 0
                            },
                            "incremental": false,
                            "max_scan_time": 0,
                            "next_run": null,
                            "profile_id": "11111111-1111-1111-1111-111111111111",
                            "profile_name": "Full Scan",
                            "report_template_id": null,
                            "scan_id": "4f132187-0458-4828-bd58-4e1c16c81a1e",
                            "schedule": {
                                "disable": false,
                                "history_limit": null,
                                "recurrence": null,
                                "start_date": null,
                                "time_sensitive": false,
                                "triggerable": false
                            },
                            "target": {
                                "address": "127.0.0.1",
                                "criticality": 10,
                                "description": "",
                                "type": "default"
                            },
                            "target_id": "eb6bd8eb-c49d-4fb4-a633-d793ab9891d8"
                        },
                        {
                            "criticality": 10,
                            "current_session": {
                                "event_level": 2,
                                "progress": 100,
                                "scan_session_id": "f7db3def-5240-48d9-8976-8b685c0d077e",
                                "severity_counts": {
                                    "high": 0,
                                    "info": 0,
                                    "low": 0,
                                    "medium": 0
                                },
                                "start_date": "2023-04-12T21:06:22.663854+08:00",
                                "status": "completed",
                                "threat": 0
                            },
                            "incremental": false,
                            "max_scan_time": 0,
                            "next_run": null,
                            "profile_id": "11111111-1111-1111-1111-111111111111",
                            "profile_name": "Full Scan",
                            "report_template_id": null,
                            "scan_id": "c569af9c-e188-42d0-abfc-0fd64614f8af",
                            "schedule": {
                                "disable": false,
                                "history_limit": null,
                                "recurrence": null,
                                "start_date": null,
                                "time_sensitive": false,
                                "triggerable": false
                            },
                            "target": {
                                "address": "127.0.0.1",
                                "criticality": 10,
                                "description": "",
                                "type": "default"
                            },
                            "target_id": "eb6bd8eb-c49d-4fb4-a633-d793ab9891d8"
                        },
                        {
                            "criticality": 10,
                            "current_session": {
                                "event_level": 2,
                                "progress": 100,
                                "scan_session_id": "65abd9d8-a781-4e07-9204-4fba0ac94d00",
                                "severity_counts": {
                                    "high": 0,
                                    "info": 0,
                                    "low": 0,
                                    "medium": 0
                                },
                                "start_date": "2023-04-12T20:47:49.036661+08:00",
                                "status": "completed",
                                "threat": 0
                            },
                            "incremental": false,
                            "max_scan_time": 0,
                            "next_run": null,
                            "profile_id": "11111111-1111-1111-1111-111111111111",
                            "profile_name": "Full Scan",
                            "report_template_id": null,
                            "scan_id": "3f74599e-6a1f-4f9d-870f-c5fce668deae",
                            "schedule": {
                                "disable": false,
                                "history_limit": null,
                                "recurrence": null,
                                "start_date": null,
                                "time_sensitive": false,
                                "triggerable": false
                            },
                            "target": {
                                "address": "202.202.0.33",
                                "criticality": 10,
                                "description": "",
                                "type": "default"
                            },
                            "target_id": "f359b506-f3ca-4df6-b62c-379480bddf0c"
                        },
                        {
                            "criticality": 10,
                            "current_session": {
                                "event_level": 2,
                                "progress": 100,
                                "scan_session_id": "ac94c7dd-f97f-4486-95a4-e0f15e4673db",
                                "severity_counts": {
                                    "high": 0,
                                    "info": 0,
                                    "low": 0,
                                    "medium": 0
                                },
                                "start_date": "2023-04-12T20:47:02.615951+08:00",
                                "status": "completed",
                                "threat": 0
                            },
                            "incremental": false,
                            "max_scan_time": 0,
                            "next_run": null,
                            "profile_id": "11111111-1111-1111-1111-111111111111",
                            "profile_name": "Full Scan",
                            "report_template_id": null,
                            "scan_id": "ef30da2a-6520-4d0b-b1d8-4aad774350d9",
                            "schedule": {
                                "disable": false,
                                "history_limit": null,
                                "recurrence": null,
                                "start_date": null,
                                "time_sensitive": false,
                                "triggerable": false
                            },
                            "target": {
                                "address": "127.0.0.1",
                                "criticality": 10,
                                "description": "",
                                "type": "default"
                            },
                            "target_id": "eb6bd8eb-c49d-4fb4-a633-d793ab9891d8"
                        },
                        {
                            "criticality": 10,
                            "current_session": {
                                "event_level": 2,
                                "progress": 100,
                                "scan_session_id": "cbe4fe7d-e040-4eec-bfc3-ecb4e69ea2af",
                                "severity_counts": {
                                    "high": 0,
                                    "info": 0,
                                    "low": 0,
                                    "medium": 0
                                },
                                "start_date": "2023-04-12T20:42:13.662705+08:00",
                                "status": "completed",
                                "threat": 0
                            },
                            "incremental": false,
                            "max_scan_time": 0,
                            "next_run": null,
                            "profile_id": "11111111-1111-1111-1111-111111111111",
                            "profile_name": "Full Scan",
                            "report_template_id": null,
                            "scan_id": "9a1078fa-49d1-4792-b27f-5e802c3bb1e3",
                            "schedule": {
                                "disable": false,
                                "history_limit": null,
                                "recurrence": null,
                                "start_date": null,
                                "time_sensitive": false,
                                "triggerable": false
                            },
                            "target": {
                                "address": "127.0.0.1",
                                "criticality": 10,
                                "description": "",
                                "type": "default"
                            },
                            "target_id": "eb6bd8eb-c49d-4fb4-a633-d793ab9891d8"
                        },
                        {
                            "criticality": 10,
                            "current_session": {
                                "event_level": 0,
                                "progress": 100,
                                "scan_session_id": "f3f7b7ee-79e9-421c-9d4f-f09535145266",
                                "severity_counts": {
                                    "high": 1,
                                    "info": 4,
                                    "low": 2,
                                    "medium": 2
                                },
                                "start_date": "2023-04-12T00:16:26.786953+08:00",
                                "status": "completed",
                                "threat": 3
                            },
                            "incremental": false,
                            "max_scan_time": 0,
                            "next_run": null,
                            "profile_id": "11111111-1111-1111-1111-111111111111",
                            "profile_name": "Full Scan",
                            "report_template_id": null,
                            "scan_id": "65febe83-3361-4f61-bc69-bd0404cbfa96",
                            "schedule": {
                                "disable": false,
                                "history_limit": null,
                                "recurrence": null,
                                "start_date": null,
                                "time_sensitive": false,
                                "triggerable": false
                            },
                            "target": {
                                "address": "http://wiki.h4rdy.me",
                                "criticality": 10,
                                "description": "url",
                                "type": "default"
                            },
                            "target_id": "56e39d8d-b369-4e89-b369-baa3c8bc8584"
                        }
                    ]
                }
                """;
        var objectMapper=new ObjectMapper();
        var jsonNode=objectMapper.readTree(json);
       jsonNode.get("scans").forEach((i)->{
           String status=removeQuote(i.get("current_session").get("status").toString());
           if(status.equals("completed"));
            System.out.println(removeQuote(i.get("scan_id").toString()));
        });
    }
    private static String removeQuote(String str)
    {
        return str.replaceAll("\"","");
    }
}
